<?PHP
if (wp_verify_nonce($_REQUEST['fets'],'fets_opts'))
	{
	$fetsopts = get_option('fets_opts');
	$fetsopts['loc'] = $_REQUEST['location'];
	$fetsopts['selected_themes'] = $_REQUEST['selected_themes'];
	update_option('fets_opts',$fetsopts);
	echo "OPTIONS UPDATED";
	//print_R($fetsopts);
	}
$fetsopts = get_option('fets_opts');
?>

<div class='fets_cont'>
	<div class='fets_left' style="float:left;width:50%;margin:2%;padding:1%;overflow:auto;height:70%;background-color:white;border:2px solid #CCC;border-radius:3px">
	<img src='<?PHP echo plugins_url('switch.png', __FILE__); ?>' style='float:left;width:100px;margin: 1px 5px'>
	<h2>Front end Theme Switcher (FETS) ** free edition **</h2>
	The front end theme switcher will display a floating theme-switching dropdown menu on your front page. Any visitor can switch to any available theme.<br/>
	See the front-end of your blog to see the theme-switcher in action.
	
		<div class='fets_left' style="width:90%;margin:2% auto;padding:2%;overflow:auto;background-color:white;border:2px solid #CCC;border-radius:3px">
		<form method='POST'>
		<h2>Option Settings</h2>
		Select a location for the selector to show:<br/>
		<select name='location'>
		<option value='TL' <?PHP if ($fetsopts['loc'] == 'TL') echo "selected"; ?>  >Top Left of the screen</option>
		<option value='TR' <?PHP if ($fetsopts['loc'] == 'TR') echo "selected"; ?> >Top Right of the screen</option>
		<option value='BL' <?PHP if ($fetsopts['loc'] == 'BL') echo "selected"; ?> >Bottom Left of the screen</option>
		<option value='BR'<?PHP if ($fetsopts['loc'] == 'BR') echo "selected"; ?> >Bottom Right of the screen</option>
		</select>
		<br/><br/>
		
		<div class='fets_left' style="width:90%;margin:2% auto;padding:2%;overflow:auto;background-color:#CCC;border:1px solid red;border-radius:3px">
		These options are available in our <a href='http://owagu.com/front-end-theme-switch-for-wordpress/' title='download the PREMIUM version'>PREMIUM version</a>
		<br><br>
		Disable the automatic floating menu and use widget instead ?<br/>
		<select name='disable_display'>
		<option value='yes' <?PHP if ($fetsopts['disable_display'] == 'yes') echo "selected"; ?> >yes disable the floating selectionbox. I will use a widget.</option>
		<option value='no' <?PHP if ($fetsopts['disable_display'] == 'no') echo "selected"; ?> >No, I like the floating box a lot !</option>
		</select><br/><br/>
		Who can see the theme selections ? : <br/>
		<select name='who'>
		<option value='admin' <?PHP if ($fetsopts['who'] == 'admin') echo "selected"; ?>>only administrators</option>
		<option value='registered' <?PHP if ($fetsopts['who'] == 'registered') echo "selected"; ?> >all registered users</option>
		<option value='all' <?PHP if ($fetsopts['who'] == 'all') echo "selected"; ?>>everyone and their brother</option>
		</select>
		<br/><br/>
		maximum amount of themes to show :<br/>
		(leave empty to show all)<br/>
		<input type='number' name='maxcount' value ='<?PHP echo $fetsopts['maxcount']; ?>' ><br/><br/>
		Select all the themes you want to include in the theme selector :<br/>
		<?PHP
		// select which themes to allow
		$count = 0;
		$themes = wp_get_themes();
		foreach ($themes as $theme)
		{
		$count++;
		echo "<INPUT NAME='selected_themes[]' TYPE='CHECKBOX' VALUE='$theme->stylesheet'";
		if (empty($fetsopts['selected_themes']) ) $fetsopts['selected_themes'] = ARRAY() ;
		if (in_array($theme->stylesheet,$fetsopts['selected_themes'])) 
				{echo "checked ><span style='color:green;font-weight:900'> $count. $theme->stylesheet</span> <br/>";}
			else 
				{ echo "> $count. $theme->stylesheet <br/>"; }
		}
		?>
		<br/><br/>
		</div>
		<br />
		<?php wp_nonce_field('fets_opts','fets'); ?>

		<input type='submit' value='submit settings' style='cursor:pointer;margin:1px auto;font-size:44px;text-align:center;padding:18px;background-color:lightyellow'>

		</form>	
		</div>
	<a href='http://owagu.com/front-end-theme-switch-for-wordpress/' title='download the PREMIUM version'>Download the PREMIUM version !</a>	
	</div>
	<div class='fets_left' style="float:left;width:36%;margin:2%;padding:1%;overflow:auto;height:70%;background-color:lightyellow;border:2px solid #CCC;border-radius:3px">
	<img src='<?PHP echo plugins_url('wppr.png', __FILE__); ?>' style='width:90%;margin:1% 4%;'>
	<h2>Latest news from wpprogrammeurs.nl :</h2>
	<?php 	
		if(function_exists('fetch_feed')) 
		{
			include_once(ABSPATH . WPINC . '/feed.php');
			$feed = 'http://wpprogrammeurs.nl/feed/';
			$rss = fetch_feed($feed);
			if (!is_wp_error( $rss ) ) :
				$maxitems = $rss->get_item_quantity(5);
				$rss_items = $rss->get_items(0, $maxitems);
				if ($rss_items):
					echo "<ul>\n";
					foreach ( $rss_items as $item ) :
						echo '<li>';
						echo '<strong><a href="' . $item->get_permalink() . '">' . $item->get_title() . "</a></strong><br />";
						echo $item->get_description() ;
						echo '</li>';
					endforeach;
					echo "</ul>\n";
				endif;
			endif;		
		}
		
	?>
	</div>
<div style='clear:both'></div>	

	<div style='text-align:center'>
	Front end Theme switcher was created by <a href='http://wpprogrammeurs.nl' title='dutch WordPress Programmers'>wpprogrammeurs.nl</a><br/>
	Are you a WP pro ? Advertise your skills for free -> <a href='http://wpfaces.com/add-a-face/' title='faces of wordpress'>faces of wordpress</a>
	</div> 
	
</div>